import request from '@/utils/request'

export function showUserList(userId) {
  let url = 'api/roles/showUserList'
  if (userId) {
    url = url + '?userId=' + userId
  }
  return request({
    url: url,
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: 'api/roles',
    method: 'post',
    data
  })
}

export function get(id) {
  return request({
    url: 'api/roles/' + id,
    method: 'get'
  })
}

export function del(ids) {
  return request({
    url: 'api/roles',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/roles',
    method: 'put',
    data
  })
}

export function editMenu(data) {
  return request({
    url: 'api/roles/menu',
    method: 'put',
    data
  })
}
export function dataScopes() {
  return request({
    url: 'api/roles/dataScope',
    method: 'get'
  })
}

export function menus(id) {
  return request({
    url: 'api/roles/menus/' + id,
    method: 'get'
  })
}

export default { add, edit, del, get, editMenu, showUserList, dataScopes, menus }
